From: robertl Date: Wed, 21 Apr 2010 05:47:50 +0000 (+0000) Subject: Add explicit casts from void* in prep for C++ migration. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~199^2~8 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=81beb8b4148eb8ea69d4c265c8d4a172d37fd6c7;p=gpsbabel.git Add explicit casts from void* in prep for C++ migration. --- diff --git a/avltree.c b/avltree.c index d6e7fb25e..08c6c6e87 100644 --- a/avltree.c +++ b/avltree.c @@ -67,7 +67,7 @@ avltree_init(const int options, const char *module) if ((module == NULL) || (*module == '\0')) fatal(MYNAME ": 'avltree_init' should be called with a valid module name!\n"); - tree = xcalloc(1, sizeof(*tree)); + tree = (avltree_t*) xcalloc(1, sizeof(*tree)); tree->options = options; tree->module = module; @@ -445,7 +445,7 @@ avltree_insert_node(avltree_t *tree, avlnode_t **root, const char *key, const vo avlnode_t *node = (*root); if (node == NULL) { - (*root) = node = xcalloc(1, sizeof(*node)); + (*root) = node = (avlnode_t*) xcalloc(1, sizeof(*node)); if (tree->options & AVLTREE_STATIC_KEYS) node->key = key; else @@ -643,7 +643,7 @@ avltree_delete_node(avltree_t *tree, const char *key, avlnode_t **root, int *cha static avlnode_t * avltree_dupe_node(const avltree_t *tree, const avlnode_t *node) { - avlnode_t *res = xcalloc(1, sizeof(*res)); + avlnode_t *res = (avlnode_t*) xcalloc(1, sizeof(*res)); if (tree->options & AVLTREE_STATIC_KEYS) res->key = node->key; diff --git a/cet.c b/cet.c index e4586249f..e88c6b316 100644 --- a/cet.c +++ b/cet.c @@ -356,7 +356,7 @@ cet_str_utf8_to_any(const char *src, const cet_cs_vec_t *vec) if (vec->ucs4_count == 0) return xstrdup(src); /* UTF-8 -> UTF-8 */ len = strlen(c); - res = dest = xmalloc(len + 1); /* target will become smaller or equal length */ + res = dest = (char *) xmalloc(len + 1); /* target will become smaller or equal length */ cend = c + len; @@ -395,7 +395,7 @@ cet_str_any_to_utf8(const char *src, const cet_cs_vec_t *vec) len += cet_ucs4_to_utf8(NULL, 6, value); } - result = cout = xmalloc(len + 1); + result = cout = (char *) xmalloc(len + 1); cin = (char *)src; while (*cin != '\0') @@ -428,7 +428,7 @@ cet_str_uni_to_utf8(const short *src, const int length) while (i-- > 0) len += cet_ucs4_to_utf8(NULL, 6, le_read16(cin++)); - res = cout = xmalloc(len + 1); + res = cout = (char *) xmalloc(len + 1); cin = (unsigned short *)src; i = length; @@ -456,7 +456,7 @@ cet_str_any_to_uni(const char *src, const cet_cs_vec_t *vec, int *length) else utf8 = cet_str_any_to_utf8(src, vec); len = cet_utf8_strlen(utf8); - res = sout = xcalloc(2, len + 1); + res = sout = (short int *) xcalloc(2, len + 1); if (len) { char *cin = utf8; diff --git a/cetus.c b/cetus.c index bb1597151..764ce29f6 100644 --- a/cetus.c +++ b/cetus.c @@ -420,7 +420,7 @@ cetus_writewpt(const waypoint *wpt) char *desc_geo; char *desc; - rec = xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1); + rec = (struct cetus_wpt_s*) xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1); if (wpt->creation_time && (NULL != (tm = gmtime(&wpt->creation_time)))){ rec->min = tm->tm_min; @@ -557,8 +557,8 @@ static int compare(const void *a, const void *b) { - const struct hdr *wa = a; - const struct hdr *wb = b; + const struct hdr *wa = (const struct hdr*) a; + const struct hdr *wb = (const struct hdr*) b; return strcmp(wa->wpt->shortname, wb->wpt->shortname); } diff --git a/csv_util.c b/csv_util.c index 9a33bfe08..d68bb9986 100644 --- a/csv_util.c +++ b/csv_util.c @@ -355,7 +355,7 @@ csv_lineparse(const char *stringstart, const char *delimited_by, } /* allocate enough space for this data field */ - tmp = xcalloc((p - sp) + 1, sizeof(char)); + tmp = (char *) xcalloc((p - sp) + 1, sizeof(char)); strncpy(tmp, sp, (p - sp)); tmp[p - sp] = '\0'; @@ -630,7 +630,7 @@ dec_to_human( char *buff, const char *format, const char *dirs, double val ) dblvals[2] = 60*(dblvals[1]-intvals[1]); intvals[2] = (int)dblvals[2]; - subformat = xmalloc( strlen(format)+2); + subformat = (char*) xmalloc( strlen(format)+2); formatptr = format; buff[0] = '\0'; @@ -697,14 +697,14 @@ xcsv_file_init(void) /* ofield is alloced to allow pointing back at ifields * where applicable. */ - xcsv_file.ofield = xcalloc(sizeof(queue), 1); + xcsv_file.ofield = (queue*) xcalloc(sizeof(queue), 1); QUEUE_INIT(xcsv_file.ofield); /* * Provide a sane default for CSV _files_. */ xcsv_file.type = ff_type_file; - xcsv_file.mkshort_handle = mkshort_new_handle(); + xcsv_file.mkshort_handle = (struct short_handle_*) mkshort_new_handle(); xcsv_file.gps_datum = GPS_DATUM_WGS84; } @@ -715,7 +715,7 @@ xcsv_file_init(void) void xcsv_ifield_add(char *key, char *val, char *pfc) { - field_map_t *fmp = xcalloc(sizeof(*fmp), 1); + field_map_t *fmp = (field_map_t *) xcalloc(sizeof(*fmp), 1); struct xt_mapping *xm = in_word_set(key, strlen(key)); fmp->key = key; @@ -734,7 +734,7 @@ xcsv_ifield_add(char *key, char *val, char *pfc) void xcsv_ofield_add(char *key, char *val, char *pfc, int options) { - field_map_t *fmp = xcalloc(sizeof(*fmp), 1); + field_map_t *fmp = (field_map_t *) xcalloc(sizeof(*fmp), 1); struct xt_mapping *xm = in_word_set(key, strlen(key)); fmp->key = key; @@ -754,7 +754,7 @@ xcsv_ofield_add(char *key, char *val, char *pfc, int options) void xcsv_prologue_add(char *prologue) { - ogue_t* ogp = xcalloc(sizeof(*ogp), 1); + ogue_t* ogp = (ogue_t*) xcalloc(sizeof(*ogp), 1); ogp->val = prologue; ENQUEUE_TAIL(&xcsv_file.prologue, &ogp->Q); @@ -768,7 +768,7 @@ xcsv_prologue_add(char *prologue) void xcsv_epilogue_add(char *epilogue) { - ogue_t * ogp = xcalloc(sizeof(*ogp), 1); + ogue_t * ogp = (ogue_t*) xcalloc(sizeof(*ogp), 1); ogp->val = epilogue; ENQUEUE_TAIL(&xcsv_file.epilogue, &ogp->Q); @@ -840,7 +840,7 @@ addhms( const char *s, const char *format ) char * ampm = NULL; int ac; - ampm = xmalloc( strlen(s) ); + ampm = (char*) xmalloc( strlen(s) ); ac = sscanf(s, format, &hour, &min, &sec, &m); /* If no time format in arg string, assume AM */ if (ac < 4) { @@ -1196,7 +1196,7 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp, wpt->sat = atoi(s); break; case XT_GPS_FIX: - wpt->fix = atoi(s)-1; + wpt->fix = (fix_type)(atoi(s)-(fix_type)1); if ( wpt->fix < fix_2d) { if (!case_ignore_strcmp(s, "none")) wpt->fix = fix_none; diff --git a/filter_vecs.c b/filter_vecs.c index 249698346..b23d0bdb7 100644 --- a/filter_vecs.c +++ b/filter_vecs.c @@ -289,8 +289,8 @@ disp_filter_vec( const char *vecname ) static signed int alpha (const void *a, const void *b) { - const fl_vecs_t *const ap = a; - const fl_vecs_t *const bp = b; + const fl_vecs_t *const ap = (const fl_vecs_t*) a; + const fl_vecs_t *const bp = (const fl_vecs_t*) b; return case_ignore_strcmp(ap->desc , bp->desc); } diff --git a/garmin_fs.c b/garmin_fs.c index f980a5196..04727478e 100644 --- a/garmin_fs.c +++ b/garmin_fs.c @@ -137,7 +137,7 @@ void garmin_fs_convert(void *fs) void garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt) { - char *phone, *addr; + const char *phone, *addr; garmin_fs_t *gmsd = GMSD_FIND(waypt); if (gmsd == NULL) return; @@ -421,4 +421,3 @@ garmin_fs_garmin_before_write(const waypoint *wpt, GPS_PWay way, const int proto GMSD_GETNSTR(cross_road, way->cross_road, sizeof(way->cross_road)); GMSD_GETNSTR(addr, way->addr, sizeof(way->addr)); } - diff --git a/gbser_posix.c b/gbser_posix.c index 665ffa338..ecf1095ad 100644 --- a/gbser_posix.c +++ b/gbser_posix.c @@ -116,7 +116,7 @@ void *gbser_init(const char *port_name) { gbser__db(4, "gbser_init(\"%s\")\n", port_name); - h = xcalloc(sizeof *h, 1); + h = (gbser_handle*) xcalloc(sizeof *h, 1); h->magic = MYMAGIC; h->vmin = h->vtime = 0; @@ -234,7 +234,7 @@ int gbser_set_port(void *handle, unsigned speed, unsigned bits, unsigned parity, unsigned gbser__read_buffer(void *handle, void **buf, unsigned *len) { gbser_handle *h = gbser__get_handle(handle); unsigned count = *len; - unsigned char *cp = *buf; + unsigned char *cp = (unsigned char *) *buf; if (count > h->inbuf_used) { count = h->inbuf_used; } @@ -348,7 +348,7 @@ int gbser_flush(void *handle) { */ int gbser_write(void *handle, const void *buf, unsigned len) { gbser_handle *h = gbser__get_handle(handle); - const char *bp = buf; + const char *bp = (const char *) buf; int rc; while (len > 0) { /*printf("write(%d, %p, %d)\n", h->fd, bp, len);*/ diff --git a/inifile.c b/inifile.c index d3b4fc923..bc8ed9148 100644 --- a/inifile.c +++ b/inifile.c @@ -163,7 +163,7 @@ inifile_load_file(gbfile *fin, inifile_t *inifile, const char *myname) if ((*cin == '\0') || (cend == NULL)) fatal("%s: invalid section header '%s' in '%s'.\n", myname, cin, gbinipathname); - sec = xcalloc(1, sizeof(*sec)); + sec = (inifile_section_t *) xcalloc(1, sizeof(*sec)); sec->name = xstrdup(cin); QUEUE_INIT(&sec->entries); @@ -178,7 +178,7 @@ inifile_load_file(gbfile *fin, inifile_t *inifile, const char *myname) if (sec == NULL) fatal("%s: missing section header in '%s'.\n", myname,gbinipathname); - entry = xcalloc(1, sizeof(*entry)); + entry = (inifile_entry_t *) xcalloc(1, sizeof(*entry)); ENQUEUE_TAIL(&sec->entries, &entry->Q); sec->ientries++; @@ -252,7 +252,7 @@ inifile_init(const char *filename, const char *myname) } else fin = gbfopen(filename, "rb", myname); - result = xcalloc(1, sizeof(*result)); + result = (inifile_t *) xcalloc(1, sizeof(*result)); QUEUE_INIT(&result->secs); inifile_load_file(fin, result, myname); diff --git a/main.c b/main.c index 778d68743..8b70f7a0b 100644 --- a/main.c +++ b/main.c @@ -42,7 +42,7 @@ typedef struct arg_stack_s { static arg_stack_t *push_args(arg_stack_t *stack, const int argn, const int argc, char *argv[]) { - arg_stack_t *res = xmalloc(sizeof(*res)); + arg_stack_t *res = (arg_stack_t *) xmalloc(sizeof(*res)); res->prev = stack; res->argn = argn; @@ -98,13 +98,13 @@ load_args(const char *filename, int *argc, char **argv[]) } gbfclose(fin); - argv2 = xmalloc(2 * sizeof(*argv2)); + argv2 = (char **) xmalloc(2 * sizeof(*argv2)); argv2[0] = xstrdup(*argv[0]); argc2 = 1; str = csv_lineparse(line, " ", "\"", 0); while (str != NULL) { - argv2 = xrealloc(argv2, (argc2 + 2) * sizeof(*argv2)); + argv2 = (char **) xrealloc(argv2, (argc2 + 2) * sizeof(*argv2)); argv2[argc2] = xstrdup(str); argc2++; str = csv_lineparse(NULL, " ", "\"", 0); diff --git a/mkshort.c b/mkshort.c index 748fd5f9f..33b1cb9d5 100644 --- a/mkshort.c +++ b/mkshort.c @@ -101,7 +101,7 @@ mkshort_new_handle() #endif { int i; - mkshort_handle *h = xxcalloc(sizeof *h, 1, file, line); + mkshort_handle *h = (mkshort_handle *) xxcalloc(sizeof *h, 1, file, line); for (i = 0; i < PRIME; i++) QUEUE_INIT(&h->namelist[i]); @@ -138,7 +138,7 @@ void add_to_hashlist(mkshort_handle *h, char *name) { int hash = hash_string(name); - uniq_shortname *s = xcalloc(1, sizeof (uniq_shortname)); + uniq_shortname *s = (uniq_shortname*) xcalloc(1, sizeof (uniq_shortname)); s->orig_shortname = xstrdup(name); ENQUEUE_TAIL(&h->namelist[hash], &s->list); @@ -159,7 +159,7 @@ mkshort_add_to_list(mkshort_handle *h, char *name) dl = sprintf(tbuf, ".%d", s->conflictctr); if (l + dl < h->target_len) { - name = xrealloc(name, l + dl + 1); + name = (char *) xrealloc(name, l + dl + 1); strcat(name, tbuf); } else { diff --git a/nmea.c b/nmea.c index 43759c83d..86f11e20a 100644 --- a/nmea.c +++ b/nmea.c @@ -331,7 +331,7 @@ nmea_wr_init(const char *portname) } } - mkshort_handle = mkshort_new_handle(); + mkshort_handle = (struct short_handle_*) mkshort_new_handle(); setshort_length(mkshort_handle, atoi(snlenopt)); if (opt_gisteq) { @@ -1345,7 +1345,9 @@ nmea_wr_posn_deinit(void) ff_vecs_t nmea_vecs = { ff_type_file, - { ff_cap_read | ff_cap_write, ff_cap_read | ff_cap_write, ff_cap_none}, + { (ff_cap)(ff_cap_read | ff_cap_write), + (ff_cap)(ff_cap_read | ff_cap_write), + ff_cap_none}, nmea_rd_init, nmea_wr_init, nmea_rd_deinit, diff --git a/pdbfile.c b/pdbfile.c index 2f9c1638f..8c852d42e 100644 --- a/pdbfile.c +++ b/pdbfile.c @@ -60,7 +60,7 @@ pdb_read_tail(gbfile *fin, gbuint32 *size) while ((count = gbfread(buff, 1, sizeof(buff), fin))) { if (!res) { - res = xmalloc(count); + res = (char *) xmalloc(count); memcpy(res, buff, count); } else { diff --git a/route.c b/route.c index bfd378d3e..14dd4dee6 100644 --- a/route.c +++ b/route.c @@ -372,7 +372,7 @@ route_copy( int *dst_count, int *dst_wpt_count, queue **dst, queue *src ) { } if ( !*dst ) { - *dst = xcalloc( 1, sizeof( queue )); + *dst = (queue *)xcalloc( 1, sizeof( queue )); QUEUE_INIT( *dst ); *dst_count = 0; *dst_wpt_count = 0; @@ -529,7 +529,7 @@ tracks_to_routes(void) void track_recompute(const route_head *trk, computed_trkdata **trkdatap) { waypoint first; - waypoint *this; + waypoint *thisw; waypoint *prev = &first; queue *elem, *tmp; int tkpt = 0; @@ -538,7 +538,7 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap) int pts_cad = 0; double tot_cad = 0.0; char tkptname[100]; - computed_trkdata *tdata = xcalloc(1, sizeof (computed_trkdata)); + computed_trkdata *tdata = (computed_trkdata *)xcalloc(1, sizeof (computed_trkdata)); if (trkdatap) { *trkdatap = tdata; @@ -555,17 +555,17 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap) time_t timed; double tlat, tlon, plat, plon, dist; - this = (waypoint *)elem; - timed = this->creation_time - prev->creation_time; + thisw = (waypoint *)elem; + timed = thisw->creation_time - prev->creation_time; /* * gcdist and heading want radians, not degrees. */ - tlat = RAD(this->latitude); - tlon = RAD(this->longitude); + tlat = RAD(thisw->latitude); + tlon = RAD(thisw->longitude); plat = RAD(prev->latitude); plon = RAD(prev->longitude); - WAYPT_SET(this, course, heading_true_degrees(plat, plon, + WAYPT_SET(thisw, course, heading_true_degrees(plat, plon, tlat, tlon)); dist = radtometers(gcdist(plat, plon, tlat, tlon)); @@ -581,63 +581,63 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap) * conditionally recompute speeds. */ if (timed && (dist > 1)) { - if(!WAYPT_HAS(this, speed)) { + if(!WAYPT_HAS(thisw, speed)) { // Only recompute speed if the waypoint // didn't already have a speed - WAYPT_SET(this, speed, dist / labs(timed)); + WAYPT_SET(thisw, speed, dist / labs(timed)); } - if (this->speed > tdata->max_spd) { - tdata->max_spd = this->speed; + if (thisw->speed > tdata->max_spd) { + tdata->max_spd = thisw->speed; } - if (this->speed < tdata->min_spd) { - tdata->min_spd = this->speed; + if (thisw->speed < tdata->min_spd) { + tdata->min_spd = thisw->speed; } } - if ((this->altitude > 0) && (this->altitude < tdata->min_alt)) { - tdata->min_alt = this->altitude; + if ((thisw->altitude > 0) && (thisw->altitude < tdata->min_alt)) { + tdata->min_alt = thisw->altitude; } - if (this->altitude > tdata->max_alt) { - tdata->max_alt = this->altitude; + if (thisw->altitude > tdata->max_alt) { + tdata->max_alt = thisw->altitude; } - if (this->heartrate > 0) { + if (thisw->heartrate > 0) { pts_hrt++; - tot_hrt += (float) this->heartrate; + tot_hrt += (float) thisw->heartrate; } - if ((this->heartrate > 0) && (this->heartrate < tdata->min_hrt)) { - tdata->min_hrt = (int) this->heartrate; + if ((thisw->heartrate > 0) && (thisw->heartrate < tdata->min_hrt)) { + tdata->min_hrt = (int) thisw->heartrate; } - if ((this->heartrate > 0) && (this->heartrate > tdata->max_hrt)) { - tdata->max_hrt = (int) this->heartrate; + if ((thisw->heartrate > 0) && (thisw->heartrate > tdata->max_hrt)) { + tdata->max_hrt = (int) thisw->heartrate; } - if (this->cadence > 0) { + if (thisw->cadence > 0) { pts_cad++; - tot_cad += (float) this->cadence; + tot_cad += (float) thisw->cadence; } - if ((this->cadence > 0) && (this->cadence > tdata->max_cad)) { - tdata->max_cad = (int) this->cadence; + if ((thisw->cadence > 0) && (thisw->cadence > tdata->max_cad)) { + tdata->max_cad = (int) thisw->cadence; } - if (this->creation_time && (this->creation_time < tdata->start)) { - tdata->start = this->creation_time; + if (thisw->creation_time && (thisw->creation_time < tdata->start)) { + tdata->start = thisw->creation_time; } - if (this->creation_time > tdata->end) { - tdata->end = this->creation_time; + if (thisw->creation_time > tdata->end) { + tdata->end = thisw->creation_time; if (tdata->start == 0) { tdata->start = tdata->end; } } - prev = this; - if (!this->shortname || !this->shortname[0] ) { + prev = thisw; + if (!thisw->shortname || !thisw->shortname[0] ) { snprintf(tkptname, sizeof(tkptname), "%s-%d", trk->rte_name ? trk->rte_name : "" , tkpt); - this->shortname = xstrdup(tkptname); + thisw->shortname = xstrdup(tkptname); } tkpt++; } diff --git a/session.c b/session.c index e3ea63aa9..0ef0e4396 100644 --- a/session.c +++ b/session.c @@ -54,7 +54,7 @@ start_session(const char *name, const char *filename) if (session_ct == 0) QUEUE_INIT(&session_list); session_ct++; - s = xcalloc(1, sizeof(*s)); + s = (session_t*) xcalloc(1, sizeof(*s)); ENQUEUE_TAIL(&session_list, &s->Q); QUEUE_INIT(&s->category_list); s->nr = session_ct; @@ -114,4 +114,3 @@ session_free(session_t *s) xfree(s->filename); xfree(s); } - diff --git a/trackfilter.c b/trackfilter.c index 118425b6b..cc138e884 100644 --- a/trackfilter.c +++ b/trackfilter.c @@ -183,8 +183,8 @@ trackfilter_parse_time_opt(const char *arg) static int trackfilter_init_qsort_cb(const void *a, const void *b) { - const trkflt_t *ra = a; - const trkflt_t *rb = b; + const trkflt_t *ra = (const trkflt_t*) a; + const trkflt_t *rb = (const trkflt_t*) b; return ra->first_time - rb->first_time; } @@ -437,7 +437,7 @@ trackfilter_merge(void) if (track_pts < 1) return; - buff = xcalloc(track_pts, sizeof(*buff)); + buff = (waypoint **)xcalloc(track_pts, sizeof(*buff)); j = 0; for (i = 0; i < track_ct; i++) /* put all points into temp buffer */ diff --git a/unicsv.c b/unicsv.c index b64e73d15..197b0bbdc 100644 --- a/unicsv.c +++ b/unicsv.c @@ -542,8 +542,8 @@ unicsv_fondle_header(char *ibuf) if (column % 4 == 0) { int sz = (column + 4) * sizeof(*unicsv_fields_tab); - if (column == 0) unicsv_fields_tab = xmalloc(sz); - else unicsv_fields_tab = xrealloc(unicsv_fields_tab, sz); + if (column == 0) unicsv_fields_tab = (field_e*) xmalloc(sz); + else unicsv_fields_tab = (field_e*) xrealloc(unicsv_fields_tab, sz); for (i = 0; i < 4; i++) unicsv_fields_tab[column + i] = fld_terminator; } @@ -1192,7 +1192,7 @@ unicsv_print_data_time(const time_t atime) static void unicsv_waypt_enum_cb(const waypoint *wpt) { - char *shortname; + const char *shortname; garmin_fs_t *gmsd; shortname = (wpt->shortname) ? wpt->shortname : ""; @@ -1267,7 +1267,7 @@ unicsv_waypt_disp_cb(const waypoint *wpt) { double lat, lon, alt; char *cout = NULL; - char *shortname; + const char *shortname; garmin_fs_t *gmsd; #ifdef UNICSV_GC_READY const geocache_data *gc_data = NULL; diff --git a/util.c b/util.c index 7c0c18e6b..3d7f16334 100644 --- a/util.c +++ b/util.c @@ -243,7 +243,7 @@ xstrappend(char *src, const char *newd) } newsz = strlen(src) + strlen(newd) + 1; - src = xxrealloc(src, newsz, file, line); + src = (char *) xxrealloc(src, newsz, file, line); strcat(src, newd); return src; @@ -338,12 +338,12 @@ xvasprintf(char **strp, const char *fmt, va_list ap) bufsize = 0; for (;;) { if (bufsize == 0) { - if ((buf = xmalloc(FIRSTSIZE)) == NULL) { + if ((buf = (char *) xmalloc(FIRSTSIZE)) == NULL) { *strp = NULL; return -1; } bufsize = FIRSTSIZE; - } else if ((newbuf = xrealloc(buf, nextsize)) != NULL) { + } else if ((newbuf = (char *) xrealloc(buf, nextsize)) != NULL) { buf = newbuf; bufsize = nextsize; } else { @@ -397,7 +397,7 @@ xvasprintf(char **strp, const char *fmt, va_list ap) if (bufsize > outsize + 1) { const unsigned ptrsz = sizeof(buf); if (((bufsize + ptrsz + 1) / ptrsz) > ((outsize + ptrsz + 1) / ptrsz)) - buf = xrealloc(buf, outsize + 1); + buf = (char *) xrealloc(buf, outsize + 1); } *strp = buf; @@ -412,7 +412,7 @@ char * pstrdup(char *src) { int len = src[0]; - char *obuf = xmalloc(len + 1); + char *obuf = (char *) xmalloc(len + 1); memcpy(obuf, src + 1, len); obuf[len] = 0; @@ -629,7 +629,7 @@ strenquote(const char *str, const char quot_char) else cin = (char *)str; len = strlen(cin); - cout = tmp = xmalloc((len * 2) + 3); + cout = tmp = (char *) xmalloc((len * 2) + 3); *cout++ = quot_char; while (*cin) { @@ -699,7 +699,7 @@ be_readu16(const void *p) void be_write16(void *addr, const unsigned value) { - unsigned char *p = addr; + unsigned char *p = (unsigned char *) addr; p[0] = value >> 8; p[1] = value; @@ -719,28 +719,28 @@ be_write32(void *pp, const unsigned i) signed int le_read16(const void *addr) { - const unsigned char *p = addr; + const unsigned char *p = (const unsigned char *) addr; return p[0] | (p[1] << 8); } unsigned int le_readu16(const void *addr) { - const unsigned char *p = addr; + const unsigned char *p = (const unsigned char *) addr; return p[0] | (p[1] << 8); } signed int le_read32(const void *addr) { - const unsigned char *p = addr; + const unsigned char *p = (const unsigned char *) addr; return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } unsigned int le_readu32(const void *addr) { - const unsigned char *p = addr; + const unsigned char *p = (const unsigned char *) addr; return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } @@ -751,8 +751,8 @@ le_readu32(const void *addr) void le_read64(void *dest, const void *src) { - char *cdest = dest; - const char *csrc = src; + char *cdest = (char *) dest; + const char *csrc = (const char *) src; if (i_am_little_endian) { memcpy(dest, src, 8); @@ -767,7 +767,7 @@ le_read64(void *dest, const void *src) void le_write16(void *addr, const unsigned value) { - unsigned char *p = addr; + unsigned char *p = (unsigned char *) addr; p[0] = value; p[1] = value >> 8; @@ -776,7 +776,7 @@ le_write16(void *addr, const unsigned value) void le_write32(void *addr, const unsigned value) { - unsigned char *p = addr; + unsigned char *p = (unsigned char *) addr; p[0] = value; p[1] = value >> 8; p[2] = value >> 16; @@ -1033,7 +1033,7 @@ void endian_write_double(void* ptr, double d, int write_le) { int i; - char *optr = ptr; + char *optr = (char *) ptr; // Word order is different on arm, but not on arm-eabi. #if defined(__arm__) && !defined(__ARM_EABI__) char r[8]; @@ -1060,7 +1060,7 @@ endian_write_float(void* ptr, float f, int write_le) { char *r = (char *)(void *)&f; int i; - char *optr = ptr; + char *optr = (char *) ptr; if ( i_am_little_endian == write_le ) { memcpy( ptr, &f, 4); @@ -1132,7 +1132,7 @@ strsub(const char *s, const char *search, const char *replace) return NULL; } - d = xmalloc(len + rlen); + d = (char *) xmalloc(len + rlen); /* Copy first part */ len = p - s; @@ -1160,11 +1160,11 @@ gstrsub(const char *s, const char *search, const char *replace) int slen = strlen(search); int rlen = strlen(replace); - o = xmalloc(olen + 1); + o = (char *) xmalloc(olen + 1); while ((c = strstr(src, search))) { olen += (rlen - slen); - o = xrealloc(o, olen + 1); + o = (char *) xrealloc(o, olen + 1); memcpy(o + ooffs, src, c - src); ooffs += (c - src); src = c + slen; @@ -1257,7 +1257,7 @@ convert_human_date_format(const char *human_datef) char prev; int ylen; - result = xcalloc((2*strlen(human_datef)) + 1, 1); + result = (char *) xcalloc((2*strlen(human_datef)) + 1, 1); cout = result; prev = '\0'; ylen = 0; @@ -1324,7 +1324,7 @@ convert_human_time_format(const char *human_timef) char *result, *cin, *cout; char prev; - result = xcalloc((2*strlen(human_timef)) + 1, 1); + result = (char *) xcalloc((2*strlen(human_timef)) + 1, 1); cout = result; prev = '\0'; @@ -1645,7 +1645,7 @@ entitize(const char * str, int is_html) #endif /* enough space for the whole string plus entity replacements, if any */ - tmp = xcalloc((strlen(str) + elen + 1), 1); + tmp = (char *) xcalloc((strlen(str) + elen + 1), 1); strcpy(tmp, str); /* no entity replacements */ @@ -1788,7 +1788,7 @@ char *get_filename(const char *fname) */ void gb_setbit(void *buf, const gbuint32 nr) { - unsigned char *bytes = buf; + unsigned char *bytes = (unsigned char *) buf; bytes[nr / 8] |= (1 << (nr % 8)); } @@ -1797,7 +1797,7 @@ void gb_setbit(void *buf, const gbuint32 nr) */ char gb_getbit(const void *buf, const gbuint32 nr) { - const unsigned char *bytes = buf; + const unsigned char *bytes = (const unsigned char *) buf; return (bytes[nr / 8] & (1 << (nr % 8))); } diff --git a/vecs.c b/vecs.c index 1d1f51504..09289c43f 100644 --- a/vecs.c +++ b/vecs.c @@ -1331,8 +1331,8 @@ static signed int alpha (const void *a, const void *b) { - const vecs_t *const *ap = a; - const vecs_t *const *bp = b; + const vecs_t *const *ap = (const vecs_t *const*) a; + const vecs_t *const *bp = (const vecs_t *const*) b; return case_ignore_strcmp((*ap)->desc , (*bp)->desc); } @@ -1363,7 +1363,7 @@ sort_and_unify_vecs(int *ctp) #endif // CSVFMTS_ENABLED - svp = xcalloc(vc, sizeof(style_vecs_t *)); + svp = (vecs_t **)xcalloc(vc, sizeof(style_vecs_t *)); /* Normal vecs are easy; populate the first part of the array. */ for (vec = vec_list; vec->vec; vec++, i++) { svp[i] = vec; @@ -1376,9 +1376,9 @@ sort_and_unify_vecs(int *ctp) /* Walk the style list, parse the entries, dummy up a "normal" vec */ for (svec = style_list; svec->name; svec++, i++) { xcsv_read_internal_style(svec->style_buf); - svp[i] = xcalloc(1, sizeof **svp); + svp[i] = (vecs_t*) xcalloc(1, sizeof **svp); svp[i]->name = svec->name; - svp[i]->vec = xmalloc(sizeof(*svp[i]->vec)); + svp[i]->vec = (ff_vecs_t*) xmalloc(sizeof(*svp[i]->vec)); svp[i]->extension = xcsv_file.extension; *svp[i]->vec = *vec_list[0].vec; /* Interits xcsv opts */ /* Reset file type to inherit ff_type from xcsv for everything @@ -1397,11 +1397,11 @@ sort_and_unify_vecs(int *ctp) switch(xcsv_file.datatype) { case 0: case wptdata: - svp[i]->vec->cap[ff_cap_rw_wpt] = ff_cap_read | ff_cap_write; break; + svp[i]->vec->cap[ff_cap_rw_wpt] = (ff_cap) (ff_cap_read | ff_cap_write); break; case trkdata: - svp[i]->vec->cap[ff_cap_rw_trk] = ff_cap_read | ff_cap_write; break; + svp[i]->vec->cap[ff_cap_rw_trk] = (ff_cap) (ff_cap_read | ff_cap_write); break; case rtedata: - svp[i]->vec->cap[ff_cap_rw_rte] = ff_cap_read | ff_cap_write; break; + svp[i]->vec->cap[ff_cap_rw_rte] = (ff_cap)(ff_cap_read | ff_cap_write); break; default: ; } svp[i]->desc = xcsv_file.description; diff --git a/vmem.c b/vmem.c index f1834f1c2..c35a02fa2 100644 --- a/vmem.c +++ b/vmem.c @@ -33,7 +33,7 @@ vmem_alloc(size_t size, int flags) if (flags & VMFL_NOZERO) vm.mem = xmalloc(size); else - vm.mem = xcalloc(size, 1); + vm.mem = (char *) xcalloc(size, 1); vm.size = size; return vm; } @@ -63,5 +63,3 @@ vmem_realloc(vmem_t *vm, size_t size) } return; } - - diff --git a/xmltag.c b/xmltag.c index 7b0471b34..2fbeaa618 100644 --- a/xmltag.c +++ b/xmltag.c @@ -71,7 +71,7 @@ copy_xml_tag( xml_tag **copy, xml_tag *src, xml_tag *parent ) { return; } - res = xcalloc( 1, sizeof(xml_tag)); + res = (xml_tag*) xcalloc( 1, sizeof(xml_tag)); *copy = res; memcpy( res, src, sizeof(xml_tag)); @@ -158,4 +158,3 @@ fs_xml *fs_xml_alloc( long type ) { result->fs.convert = fs_xml_convert; return result; } -